/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author msc
 */
@Entity
@Table(name = "AccountInBank")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AccountInBank.findAll", query = "SELECT a FROM AccountInBank a"),
    @NamedQuery(name = "AccountInBank.findByAccountId", query = "SELECT a FROM AccountInBank a WHERE a.accountId = :accountId"),
    @NamedQuery(name = "AccountInBank.findByPassword", query = "SELECT a FROM AccountInBank a WHERE a.password = :password"),
    @NamedQuery(name = "AccountInBank.findBySetDate", query = "SELECT a FROM AccountInBank a WHERE a.setDate = :setDate")})
public class AccountInBank implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "AccountId")
    private Integer accountId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 127)
    @Column(name = "Password")
    private String password;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SetDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date setDate;
    @JoinColumn(name = "AccountTypeId", referencedColumnName = "AccountTypeId")
    @ManyToOne
    private TypeOfAccount accountTypeId;
    @JoinColumn(name = "EmployeeId", referencedColumnName = "EmployeeId")
    @ManyToOne
    private Employee employeeId;
    @OneToMany(mappedBy = "accountId")
    private Collection<TransactionRecord> transactionRecordCollection;

    public AccountInBank() {
    }

    public AccountInBank(Integer accountId) {
        this.accountId = accountId;
    }

    public AccountInBank(Integer accountId, String password, Date setDate) {
        this.accountId = accountId;
        this.password = password;
        this.setDate = setDate;
    }

    public Integer getAccountId() {
        return accountId;
    }

    public void setAccountId(Integer accountId) {
        this.accountId = accountId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getSetDate() {
        return setDate;
    }

    public void setSetDate(Date setDate) {
        this.setDate = setDate;
    }

    public TypeOfAccount getAccountTypeId() {
        return accountTypeId;
    }

    public void setAccountTypeId(TypeOfAccount accountTypeId) {
        this.accountTypeId = accountTypeId;
    }

    public Employee getEmployeeId() {
        return employeeId;
    }

    public void setEmployeeId(Employee employeeId) {
        this.employeeId = employeeId;
    }

    @XmlTransient
    public Collection<TransactionRecord> getTransactionRecordCollection() {
        return transactionRecordCollection;
    }

    public void setTransactionRecordCollection(Collection<TransactionRecord> transactionRecordCollection) {
        this.transactionRecordCollection = transactionRecordCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accountId != null ? accountId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AccountInBank)) {
            return false;
        }
        AccountInBank other = (AccountInBank) object;
        if ((this.accountId == null && other.accountId != null) || (this.accountId != null && !this.accountId.equals(other.accountId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.AccountInBank[ accountId=" + accountId + " ]";
    }
    
}
